package week9;

/**
 *
 * 771. 宝石与石头
 * https://leetcode-cn.com/problems/jewels-and-stones/
 *
 *
 * 执行结果：  通过  显示详情
 *
 * 添加备注
 * 执行用时：0 ms, 在所有 Java 提交中击败了100.00% 的用户
 * 内存消耗：36.6 MB, 在所有 Java 提交中击败了87.62% 的用户
 * 通过测试用例：255 / 255
 * 炫耀一下:
 */
public class Week9JewelsAndStones {

    public int numJewelsInStones(String jewels, String stones) {
        int jewelsCount = 0;
        int jewelsLength = jewels.length();
        int stonesLength = stones.length();
        for(int stoneSize = 0; stoneSize < stonesLength; stoneSize++) {
            char stone = stones.charAt(stoneSize);
            for(int jewelSize = 0; jewelSize < jewelsLength; jewelSize++) {
                char jewel = jewels.charAt(jewelSize);
                if(stone == jewel) {
                    jewelsCount++;
                    break;
                }
            }
        }
        return jewelsCount;
    }

}
